﻿namespace WFBot.Data.Configuration
{
    using Framework.Domain;
    using Microsoft.Data.Objects;

    public class QuestionConfiguration : EntityConfiguration<Question>
    {
        public QuestionConfiguration()
        {
            HasKey(q => q.Id);

            Property(q => q.Id).IsIdentity();
            Property(q => q.IsActive);
            Property(q => q.IsIdentifier);
            Property(q => q.Text).IsUnicode().IsRequired().IsVariableLength().HasMaxLength(500);
            Property(q => q.Options).IsUnicode().IsVariableLength().HasMaxLength(500);
            Property(q => q.InternalType);

            MapSingleType(q => new
            {
                q.Id,
                q.IsActive,
                q.IsIdentifier,
                q.Text,
                q.Options,
                Type = q.InternalType
            }).ToTable("Questions");
        }
    }
}
